- function g(a){return `${a<10?"0":""}${a}`} let FileURI = `${d.getFullYear()}-${g(d.getMonth()+1)}-${g(d.getDate())}.txt`
extends layout
block content
    style.
        #btnView{text-align: center}
        .btnlist{margin: 10px auto;display: inline-block}
        .btnlist *{margin:0 10px}
    script.
        let vm
        window.onload=()=>{
            vm = new Vue({
                el:"#userData",
                data:{
                    now:{name:"",phone_a:"",phone_b:"",address:"",timecode:""},history:{name:"",phone_a:"",phone_b:"",address:"",timecode:""},
                    id:1,loading:true},
                methods:{
                    pushData(){
                        if(!this.loading){
                            let a = this.now
                            if(a.timecode.trim()==""||a.phone_a.trim()==""||a.phone_b.trim()==""||a.name.trim()==""||a.address.trim()==""){
                                mdui.snackbar("请输入填写时间和人员信息")
                            }else{
                                this.loading=true
                                axios.post('push',{id:a.name,a:a.phone_a,b:a.phone_b,address:a.address,time:a.timecode}).then(a=>{
                                    this.loading=false;
                                    if(!a.data.code){
                                        this.history = this.now
                                        this.now={name:"",phone_a:"",phone_b:"",address:"",timecode:""}
                                    }
                                    mdui.snackbar(a.data.msg)
                                    this.next('#name')
                                }).catch(a=>{
                                    this.loading=false;
                                    mdui.snackbar(a)
                                })
                            }
                        }
                    },
                    next(a){
                        let item = document.querySelector(a)
                        if(item&&a) item.focus();
                    },getData(){
                        function g(a){return `${a<10?"0":""}${a}`}
                        if(!this.loading){
                            this.loading=true
                            let d = new Date()
                            axios.post('get',{data:`${d.getFullYear()}-${g(d.getMonth()+1)}-${g(d.getDate())}`}).then(a=>{
                                let Coo = `已提交数量：${a.data.data.length}<br>` + a.data.data.map(a=>a=`${a.uid}|${a.phone.split('|').join('****')}|${a.address}`).join('<br>')
                                mdui.dialog({title:"当日存档数据",content:Coo})
                                this.loading=false;
                            }).catch(a=>{
                                mdui.snackbar(a)
                                this.loading=false;
                            })
                        }                        
                    },ClearData(){
                        this.now={name:"",phone_a:"",phone_b:"",address:"",timecode:""}
                    }
                },
                updated(){
                    mdui.mutation()
                },
                mounted(){
                    this.loading=false
                }
            })
        }
    div#userData
        br
        div.mdui-progress(v-show="loading")
            div.mdui-progress-indeterminate
        br
        div(v-show="history.name!=''")
            div 上次成功推送的记录：
            div 
                span(v-text="history.name")
                span :
                span(v-text="history.phone_a")
                span ****
                span(v-text="history.phone_b")
                span ,address:
                span(v-text="history.address")
        div.mdui-textfield
            div.mdui-textfield-label *输入姓名或用户唯一标识
            input.mdui-textfield-input#name(v-model.text="now.name" @keypress.enter="next('#phone_a')" autocomplete="off")
        div.mdui-textfield
            div.mdui-textfield-label *输入手机号前几位
            input.mdui-textfield-input#phone_a(v-model.text="now.phone_a" @keypress.enter="next('#phone_b')" autocomplete="off")
        div.mdui-textfield
            div.mdui-textfield-label *输入手机号后几位
            input.mdui-textfield-input#phone_b(v-model.text="now.phone_b" @keypress.enter="next('#address')" autocomplete="off")
        div.mdui-textfield
            div.mdui-textfield-label *输入地理位置
            input.mdui-textfield-input#address(v-model.text="now.address" @keypress.enter="next('#time')" autocomplete="off")
        div.mdui-textfield
            div.mdui-textfield-label 输入查询时间
            input.mdui-textfield-input#time(v-model.text="now.timecode" @keypress.enter="next('#push')" autocomplete="off")
        div#btnView
            div.btnlist
                button#push.mdui-btn.mdui-btn-raised.mdui-ripple.mdui-color-theme-accent(@click='pushData') 提交
                button#jump.mdui-btn.mdui-btn-raised.mdui-ripple.mdui-color-theme-accent(@click='getData') 查看
                button#dele.mdui-btn.mdui-btn-raised.mdui-ripple.mdui-color-theme-accent(@click='ClearData') 清空本页